package event

import ext.byteArg

/**
 * 获取扫描返回
 */
class DeliveryScanResultEvent(val row: Int, val col: Int, val state: Int) {
    companion object {
        fun withByteArray(byteArray: ByteArray): DeliveryScanResultEvent {
            val row = byteArray.byteArg(1)
            val col = byteArray.byteArg(2)
            val state = byteArray.byteArg(3)
            return DeliveryScanResultEvent(row, col, state)
        }
    }

    fun isNotEmpty() = state == 0x81
    fun isFinish() = state == 0x00
    fun isError() = (state == 0x10) || (state == 0x11)
}